package Interface.User;

import Interface.Admin.tongJiHuiYuan;
import Mapper.Admin.huiYuanMapper;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import liaotian.Client;

import java.io.FileInputStream;

public class User extends Application {
    public static String name;
    huiYuanMapper huiYuanMapper;

    @Override
    public void start(Stage stage) throws Exception {
        FileInputStream input=new FileInputStream("C:\\Users\\86178\\Videos\\R-C.jpg");
        Image image = new Image(input);
        ImageView imageView =new ImageView(image);
        imageView.setFitWidth(488);
        imageView.setFitHeight(465);
        huiYuanMapper=new huiYuanMapper();

        Button huiYuan = new Button("查询会员信息");
        huiYuan.setOnAction(e -> huiYuan());

        Button keCheng = new Button("查询课程信息");
        keCheng.setOnAction(e->keCheng());


        Button jianShenHuoDong = new Button("健身活动通知");
        jianShenHuoDong.setOnAction(e->jianShenHuoDong());

        Button shouHouFuWu = new Button("联系客服");
        shouHouFuWu.setOnAction(e->shouHouFuWu());

        Pane pane = new Pane();
        pane.getChildren().add(imageView);
        pane.getChildren().addAll(huiYuan,keCheng,jianShenHuoDong,shouHouFuWu);

        huiYuan.setLayoutX(0);
        huiYuan.setLayoutY(0);

        keCheng.setLayoutX(0);
        keCheng.setLayoutY(50);


        jianShenHuoDong.setLayoutX(0);
        jianShenHuoDong.setLayoutY(100);

        shouHouFuWu.setLayoutX(0);
        shouHouFuWu.setLayoutY(150);


        Scene scene =new Scene(pane);
        stage.setScene(scene);
        stage.setTitle("华凌健身房");
        stage.setWidth(500);
        stage.setHeight(500);
        stage.setResizable(false);//窗口不可拉伸
        stage.show();
    }

    /**
     * 售后服务
     */
    private void shouHouFuWu() {

        liaotian.Client client =new Client();
        name= huiYuanMapper.getName(Controller.Client.id);
        liaotian.Client.nickname=name;
        client.start(new Stage());
    }

    /**
     * 健身活动
     */
    private void jianShenHuoDong() {
        jianShenHuoDong jianShenHuoDong =new jianShenHuoDong();
        try {
            jianShenHuoDong.start(new Stage());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }



    /**
     * 课程
     */
    private void keCheng() {
        keCheng keCheng =new keCheng();
        try {
            keCheng.start(new Stage());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询会员信息
     */
    private void huiYuan() {
        huiYuan huiYuan =new huiYuan();
        try {
            huiYuan.start(new Stage());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
